package priv.jesse.mall.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import priv.jesse.mall.entity.Shopcart;
import javax.transaction.Transactional;
import java.util.List;

public interface ShopcartDao extends JpaRepository<Shopcart, Integer> {

    /**
     * 加载购物车
     * @param
     * @return
     */
    @Query(value = "select id,pro_id,buy_count,state,user_id from shopcart where state=0 and user_id= :id",nativeQuery = true)
    List<Shopcart> loadlistCart(@Param("id") int id);

    @Transactional
    void deleteById(int id);

    @Transactional
    Shopcart findById(int id);





}
